/**
 * 项目列表
 */
import query from '../../untils/mysql';
import { Tip } from '../../untils/untils';
import { check, validationResult } from 'express-validator';
const validator = [
    check('projectId').notEmpty().withMessage("项目Id不能为空！"),
]

const GET = async (req: any, res: any, next: any) => {
    try {
        const { projectId } = req.query;
        var errors = validationResult(req);
        if (!errors.isEmpty()) {
            return Tip.tipError(res, errors.array()[0].msg);
        }
        const sql = `select b.*,c.name projectName from project_pople a left join user b on a.pople_id = b.id left join project c on a.project_id = c.id where project_id = '${projectId}'`
        const data = await query(sql);
        data.forEach(item => {
            delete item.password
        })
        return Tip.tipSuccess(res, '查询成功', data)
    } catch (error: any) {
        Tip.tipError500(res, error)
    }
}

export {
    GET,
    validator
}